import java.io.*;
import java.security.KeyFactory;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;

public class GenquaKeyGen {

	private static String reg;

	public GenquaKeyGen() {
	}

	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("Clover-------------");
		System.out.print("Input your name:");
		String corp = br.readLine();
		long now = System.currentTimeMillis();
		
		reg = (new StringBuilder("1010^^")).append(now).append("^^")
				.append(now).append("^^").append(corp).append("^^1").toString();

		System.out.print(generateKey(corp));
	}

	public static String generateKey(String corp) throws Exception {
		byte privateEncoded[] = { 48, -126, 1, 75, 2, 1, 0, 48, -126, 1, 44, 6,
				7, 42, -122, 72, -50, 56, 4, 1, 48, -126, 1, 31, 2, -127, -127,
				0, -3, 127, 83, -127, 29, 117, 18, 41, 82, -33, 74, -100, 46,
				-20, -28, -25, -10, 17, -73, 82, 60, -17, 68, 0, -61, 30, 63,
				-128, -74, 81, 38, 105, 69, 93, 64, 34, 81, -5, 89, 61, -115,
				88, -6, -65, -59, -11, -70, 48, -10, -53, -101, 85, 108, -41,
				-127, 59, -128, 29, 52, 111, -14, 102, 96, -73, 107, -103, 80,
				-91, -92, -97, -97, -24, 4, 123, 16, 34, -62, 79, -69, -87,
				-41, -2, -73, -58, 27, -8, 59, 87, -25, -58, -88, -90, 21, 15,
				4, -5, -125, -10, -45, -59, 30, -61, 2, 53, 84, 19, 90, 22,
				-111, 50, -10, 117, -13, -82, 43, 97, -41, 42, -17, -14, 34, 3,
				25, -99, -47, 72, 1, -57, 2, 21, 0, -105, 96, 80, -113, 21, 35,
				11, -52, -78, -110, -71, -126, -94, -21, -124, 11, -16, 88, 28,
				-11, 2, -127, -127, 0, -9, -31, -96, -123, -42, -101, 61, -34,
				-53, -68, -85, 92, 54, -72, 87, -71, 121, -108, -81, -69, -6,
				58, -22, -126, -7, 87, 76, 11, 61, 7, -126, 103, 81, 89, 87,
				-114, -70, -44, 89, 79, -26, 113, 7, 16, -127, -128, -76, 73,
				22, 113, 35, -24, 76, 40, 22, 19, -73, -49, 9, 50, -116, -56,
				-90, -31, 60, 22, 122, -117, 84, 124, -115, 40, -32, -93, -82,
				30, 43, -77, -90, 117, -111, 110, -93, 127, 11, -6, 33, 53, 98,
				-15, -5, 98, 122, 1, 36, 59, -52, -92, -15, -66, -88, 81, -112,
				-119, -88, -125, -33, -31, 90, -27, -97, 6, -110, -117, 102,
				94, -128, 123, 85, 37, 100, 1, 76, 59, -2, -49, 73, 42, 4, 22,
				2, 20, 47, 68, -69, -31, -71, 91, 80, 18, 90, 74, 31, 15, -49,
				3, -26, 105, -82, 71, 5, 66 };
		PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateEncoded);
		KeyFactory keyfactory = KeyFactory.getInstance("DSA");
		java.security.PrivateKey privateKey = keyfactory
				.generatePrivate(keySpec);
		Signature signature = Signature.getInstance("SHA1withDSA");
		signature.initSign(privateKey);
		String crypt = encode(reg.getBytes());
		signature.update(reg.getBytes());
		byte digest[] = signature.sign();
		String diestStr = encode(digest);
		int lineLength = diestStr.length() / 2;
		StringBuffer license = new StringBuffer();
		license.append(diestStr.substring(0, lineLength));
		license.append("\n");
		license.append(diestStr.substring(lineLength));
		license.append("\n");
		license.append(crypt.substring(0, lineLength));
		license.append("\n");
		license.append(crypt.substring(lineLength));
		return license.toString();
	}

	public static String encode(byte abyte0[]) {
		char ac[] = new char[abyte0.length * 2];
		for (int i = 0; i < abyte0.length; i++) {
			byte byte0 = abyte0[i];
			if (-128 <= byte0 && byte0 < -64) {
				ac[i] = randomWord(0);
				ac[abyte0.length + i] = encode(byte0 + 128);
			} else if (-64 <= byte0 && byte0 < 0) {
				ac[i] = randomWord(1);
				ac[abyte0.length + i] = encode(byte0 + 64);
			} else if (byte0 >= 0 && byte0 < 64) {
				ac[i] = randomWord(2);
				ac[abyte0.length + i] = encode(byte0);
			} else if (64 <= byte0 && byte0 < 128) {
				ac[i] = randomWord(3);
				ac[abyte0.length + i] = encode(byte0 - 64);
			} else {
				System.out
						.println((new StringBuilder("Invalid Char in stream "))
								.append(byte0).toString());
			}
		}

		String s = new String(ac);
		return s;
	}

	private static char randomWord(int feed) {
		int j = feed * 6 + (int) (Math.random() * 6D);
		boolean flag = (int) (Math.random() * 2D) < 1;
		return (char) (j + (flag ? 97 : 65));
	}

	private static char encode(int i) {
		if (i >= 0 && i <= 9)
			return (char) (i + 48);
		if (10 <= i && i <= 35)
			return (char) ((i - 10) + 65);
		if (36 <= i && i <= 61)
			return (char) ((i - 36) + 97);
		if (i == 62)
			return '<';
		if (i == 63) {
			return '>';
		} else {
			System.out.println((new StringBuilder("Invalid int in stream "))
					.append(i).toString());
			return '\0';
		}
	}
}
